<template>
	<view class="fun-flex-col page">	
		<view class="fun-flex-row fun-justify-between fun-items-center list"
			v-for="(item, index) in fileList"
			:key="index"
			@click="preview(item)"
		>
			<template v-if='item.name'>
				<text>{{item.name}}</text>
				<image src="@/static/common/arrow_right_black.png" />
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList:[]
			};
		},
		
		onLoad(option) {
			const data = option?.fileData || "";
			if(data){
				this.fileList = JSON.parse(data)
			}
		},

		methods: {
			preview(item){
				// window.open(item.downUrl);
				// plus.runtime.openWeb(item.downUr);
				// plus.runtime.openURL(item.downUr)
				// plus.webview.open(item.downUr)
				uni.downloadFile({
				  url: item.downUr,
				  success: function (res) {
				    var filePath = res.tempFilePath;
				    uni.openDocument({
				      filePath: filePath,
				      showMenu: true,
				      success: function (res) {
				        console.log('打开文档成功');
				      }
				    });
				  }
				});
			}
		},
	};
</script>

<style scoped lang="scss">
	.page {
		background-color: #ffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
		padding: 0 32rpx;
		.list {
			padding: 32rpx 0;
			border-bottom: 2rpx solid #D9D9D9;
			image {
				width: 48rpx;
				height: 48rpx;
			}
			text{
				color: #1d1d25;
			}
		}
	}
</style>